package ru.lenwp.dao;

import org.springframework.jdbc.core.JdbcTemplate;
import ru.lenwp.model.EntryWithId;

import javax.sql.DataSource;
import java.sql.Connection;

/**
 * Created by Lenar on 26.09.2014.
 */
public abstract class AbstractDao<T extends EntryWithId> {
    protected DataSource dataSource;

    public JdbcTemplate getTemlate() {
        return temlate;
    }

    protected JdbcTemplate temlate;

    public void setDataSource(DataSource dataSource) {
        this.dataSource = dataSource;
        this.temlate = new JdbcTemplate(dataSource);
    }

    public abstract long insert(T entry);

    public abstract void update(T entry);

    public abstract T findById(long id);

    public abstract void delete(T entry);
}
